from typing import Optional, AsyncGenerator
from fastapi import Depends, Request
from utils.uow import UnitOfWork


async def get_uow() -> AsyncGenerator[UnitOfWork, None]:
    async with UnitOfWork() as uow:
        yield uow


def get_cookie_token(request: Request) -> Optional[str]:
    return request.cookies.get("token")


uow_dep = Depends(get_uow)
auth_dep = Depends(get_cookie_token)
